// Sunghan Cho
// 301140084
// sunghanc@sfu.ca

#ifndef UIITEMTABLEWIDGET_H
#define UIITEMTABLEWIDGET_H

#include "itemlistmodel.h"

#include <QWidget>
#include <QItemSelection>

namespace Ui {
	class UiItemTableWidget;
}

/*
 * A UI table view which supports item selection and
 * displaying a title for the section. Relies on a
 * ItemListModel for its data and to relay selection signals.
 *
 * by Brian Fraser, 2012
 */
class UiItemTableWidget : public QWidget
{
	Q_OBJECT

public:
	static const int INVALID_SELECTION = -1;

public:
	explicit UiItemTableWidget(QWidget *parent = 0);
	~UiItemTableWidget();

	void setModel(ItemListModel *pModel);
	void setDescription(QString description);

public slots:
	void clearAllSelections();
	void redrawColumns();

private slots:
	void tableSelectionChanged(QItemSelection selected);
	void tableClicked(QModelIndex selected);

signals:
	void notifySetSelected(int selectedId);

private:
	Ui::UiItemTableWidget *ui;
	ItemListModel *m_pModel;
};

#endif // UIITEMTABLEWIDGET_H
